package visiopuce.action;

import org.eclipse.jface.action.Action;
import org.eclipse.jface.dialogs.MessageDialog;
import org.eclipse.ui.IWorkbenchWindow;
import org.eclipse.ui.PartInitException;

import visiopuce.ICommandIds;
import visiopuce.ui.view.ReunionPuceView;

public class ReunionPuceAction extends Action {

	private final IWorkbenchWindow window;

	public ReunionPuceAction(String text, IWorkbenchWindow window) {
		super(text);
		this.window = window;
		// The id is used to refer to the action in a menu or toolbar
		setId(ICommandIds.CMD_REUNION_PUCE);
		// Associate the action with a pre-defined command, to allow key
		// bindings.
		setActionDefinitionId(ICommandIds.CMD_REUNION_PUCE);
		setImageDescriptor(visiopuce.Activator.getImageDescriptor("/icons/reunion.png"));
	}

	public void run() {
		try {
			window.getActivePage().showView("visiopuce.reunionPuceView");
			ReunionPuceView view = (ReunionPuceView) window.getActivePage().findView("visiopuce.reunionPuceView");
		} catch (PartInitException e) {
			MessageDialog.openError(window.getShell(), "Error", "Erreur lors de l'ouverture de la vue de la réunion puce :" + e.getMessage());
		}

	}
}